package com.service.impl;

import com.dao.Td_tblPartyRelationshipTransferDao;
import com.entity.Td_tblPartyRelationshipTransfer;
import com.service.inte.Td_tblPartyRelationshipTransferServiceInte;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class Td_tblPartyRelationshipTransferServiceImpl implements Td_tblPartyRelationshipTransferServiceInte {

    @Autowired
    private Td_tblPartyRelationshipTransferDao td_tblPartyRelationshipTransferDao;

    @Transactional
    @Override
    public int save(Td_tblPartyRelationshipTransfer td_tblPartyRelationshipTransfer) {
        td_tblPartyRelationshipTransferDao.save(td_tblPartyRelationshipTransfer);
        return 1;
    }

    @Override
    public List<Object[]> getFinishByName(String Name, int branchId, int page){
        return td_tblPartyRelationshipTransferDao.getFinishByName("%"+Name+"%",branchId,new PageRequest(page,10));
    }

    @Override
    public List<Object[]> getBeFinishByName(String Name, int branchId, int page){
        return td_tblPartyRelationshipTransferDao.getBeFinishByName("%"+Name+"%",branchId,new PageRequest(page,10));
    }

    @Override
    public List<Object[]> getNoFinishByName(String Name, int branchId, int page){
        return td_tblPartyRelationshipTransferDao.getNoFinishByName("%"+Name+"%",branchId,new PageRequest(page,10));
    }

    @Override
    public Td_tblPartyRelationshipTransfer getById(int id){
        return td_tblPartyRelationshipTransferDao.getByFd_ID(id);
    }

    @Override
    public int memberTransferCount(int loginId) {
        return td_tblPartyRelationshipTransferDao.memberTransferCount(loginId);
    }

    @Override
    public List<Object[]> getAllFinishByLoginId(int loginId, int page) {
        return td_tblPartyRelationshipTransferDao.getNoFinishByLoginId(loginId,PageRequest.of(page,10));
    }
}
